<?php
/**
 * 获取医嘱信息
 * @authors xiadx (xiadx@zpdchina.com)
 * @date    2017-02-24 11:56:24
 * @version $Id$
 */

class GetyizhuallinfojsonController extends Yaf_Controller_Abstract {

    public function yizhuHistoryDataUploadAction()
    {
/*        if ($exception->getCode() == 516 && !headers_sent())
        {
            header('HTTP/1.1 404 Not Found', TRUE, 404);
            header('status: 404 Not Found', TRUE, 404);
//            exit();
            return FALSE;
        }*/
        // $html = Kohana_Exception::handler($exception);
        // $data = $this->getRequest()->getQuery('data', []);
        // print_r($request->getPost());exit;
        // $upload_data = $request->getPost('user_department', '');
        $yizhu_d = isset($_REQUEST['data']) ? $_REQUEST['data'] : [];
        // print_r($yizhu_d);exit;
        $mod = new YizhuHistoryModel;
        $mod->addYizhuHistory($yizhu_d);
        // print_r($mod->getList());
        /*foreach ($mod->getList() as $key => $value) {
            print_r($value);
        }*/
//		$this->getView()->assign("exception", $exception);
        return FALSE;
    }


    /**
     * 获取所有医嘱
     * @return [type] [description]
     */
    public function indexAction()
    {
        $request = $this->getRequest();
        $user_department_id = $request->getPost('zhuyuan_id', '');
        $user_department = $request->getPost('user_department', '');
        if($user_department == "")
        {
            Utility::apiJsonError(20031, '科室不能为空');
        }

        $modify_time = $request->getPost('modify_time', '');

        $jsonData = $request->getPost('data', '');
        /*是否开启压缩 默认开启*/
        $compression_http_data = $request->getPost('compression_http_data', 'off');
        // 解压缩数据
        $jsonData = Utility::uncompress($jsonData,$compression_http_data);
        // 医嘱模型
        $mod_yizhu = new YizhuAllInfoModel;
        $async_result['error'] = 200;
        $async_result['msg'] = '';
        $async_result['update_sql'] = $mod_yizhu->getAllYizhu($user_department, $user_department_id, $modify_time, $jsonData);
        Utility::apiJsonResultExtends($async_result);
    }
}
